package com.yiligi.myserver.mapper;

import com.yiligi.myserver.pojo.Files;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FileMapper {

    @Select("select * from sys_file")
    List<Files> selectAllFile();

    int selectFileCount(@Param("name") String name,@Param("type") String type);

    List<Files> selectFilePage(
            @Param("pageNum")int pageNum,
            @Param("pageSize")int pageSize,
            @Param("name")String name,
            @Param("type")String type);

    @Insert("insert into sys_file(name, type, size, url, md5, is_delete, enable)"+
            " VALUES(#{name},#{type},#{size},#{url},#{md5},#{is_delete},#{enable}) ")
    int uploadFile(Files files);

    @Update("update sys_file set is_delete = 1 where id = #{id}")
    int deleteFile(@Param("id") int id);

    Boolean delBatchFile(List<Integer> files);

    @Select("select * from sys_file where md5 = #{md5}")
    List<Files> getFileMd5(@Param("md5") String md5);

    @Select("select url from sys_file where url=#{avatar_url}")
    String getUrl(@Param("avatar_url")String avatar_url);
}
